package com.yehangtech.designpattern.结构型_享元模式.factory;


import com.yehangtech.designpattern.结构型_享元模式.entity.Activity;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

public class ActivityFactory {
    static Map<Long, Activity> activityMap = new HashMap<>();
    public static Activity getActivity(Long id) {
        Activity activity = activityMap.get(id);
        if (null == activity) {
            // 模拟从实际业务应⽤从接⼝中获取活动信息
            activity = new Activity();
            activity.setId(10001L);
            activity.setName("双十一优惠专场");
            activity.setDesc("双十一优惠专场-手机优惠");
            activity.setStartTime(new Date());
            activity.setStopTime(new Date());
            activityMap.put(id, activity);
        }
        return activity;
    }
}
